{% extends 'shop/base.html' %}

{% block title %}Inbox{% endblock %}

{% block content %}
<h1 class="mb-6 text-3xl">Inbox</h1>

<div class="space-y-6">
{% if conversations %}
    {% for conversation in conversations %}
        <a href="{% url 'conversation:detail' conversation.id %}">
            <div class="p-6 flex bg-gray-100 rounded-xl">
                <div class="pr-6">
                    <img src="{{ conversation.item.image.url }}" class="w-20 rounded-xl">
                </div>

                <div>
                    {% for member in conversation.members.all %}
                        {% if member != request.user %}
                            <p class="mb-4"><strong>{{ member.username }}</strong> | {{ conversation.modified_at }}</p>
                            <p>{{ conversation.item.name }}</p>
                        {% endif %}
                    {% endfor %}
                </div>
            </div>
        </a>
    {% endfor %}
{% else %}
    <h4>目前没有任何对话消息</h4>
{% endif %}
</div>
{% endblock %}
